<template>
  <div flex flex-wrap pt-36rpx pb-100rpx>
    <div v-for="(item, index) in goodsList" :key="index" :style="'width: 50%'">
      <twoRow :res="item" />
    </div>
  </div>
</template>

<script setup lang="ts">
import { getGoodsList } from '@/api/goods';
import twoRow from '@/components/goods-list/2row.vue';
const props = defineProps<{
  res: any
}>()
const goodsList = ref<any>([])
watch(() => props.res, async (val) => {
  if (val) {
    init()
  }
}, { immediate: true, deep: true })

async function init() {
  const result = await getGoodsList({
    pageNumber: 1,
    pageSize: 10,
    category: props.res.categoryPath,
  })
  if (result.data.success) {
    goodsList.value = result.data.result.records
  }
}

</script>

<style scoped></style>
